import {requestService} from '/src/utils/request'
import {praseStrEmpty} from "/src/utils/DateUtile";

// 查询用户列表
export function getUserList(queryParams) {
    return requestService({
        url: '/xiaozhen-system/sysUser/list',
        method: 'get',
        params: queryParams
    })
}

// 用户状态修改
export function changeUserStatus(userId, status) {
    const data = {
        userId,
        status
    }
    return requestService({
        url: '/xiaozhen-system/sysUser/changeUserStatus',
        method: 'put',
        data: data
    })
}

// 查询用户详细
export function getUser(userId) {
    return requestService({
        url: '/xiaozhen-system/sysUser/' + praseStrEmpty(userId),
        method: 'get'
    })
}

// 新增用户
export function addUser(data) {
    return requestService({
        url: '/xiaozhen-system/sysUser/add',
        method: 'post',
        data: data
    })
}

// 修改用户
export function updateUser(data) {
    return requestService({
        url: '/xiaozhen-system/sysUser/update',
        method: 'put',
        data: data
    })
}

// 删除用户
export function delUser(userId) {
    return requestService({
        url: '/xiaozhen-system/sysUser/' + userId,
        method: 'delete'
    })
}


// 查询用户个人信息
export function getUserProfile() {
    return requestService({
        url: '/xiaozhen-system/sysUser/profile',
        method: 'get'
    })
}

// 修改用户个人信息
export function updateUserProfile(data) {
    return requestService({
        url: '/xiaozhen-system/sysUser/profile',
        method: 'put',
        data: data
    })
}

// 用户密码重置
export function updateUserPwd(oldPassword, newPassword) {
    const data = {
        oldPassword,
        newPassword
    }
    return requestService({
        url: '/xiaozhen-system/sysUser/profile/updatePwd',
        method: 'put',
        params: data
    })
}

// 用户头像上传
export function uploadAvatar(data) {
    return requestService({
        url: '/xiaozhen-system/sysUser/profile/avatar',
        method: 'post',
        data: data
    })
}
